﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LoableTech;

namespace DesktopCam
{
    internal class AutoUpdaterCoreFunc
    {
     
        /// <summary>
        /// 
        /// </summary>
        /// <param name="serviceName">更新前需要关闭的systemd服务</param>
        public static void StartUpdate(string serviceName = null)
        {
            AutoUpdater.UpdateDownloadedEvent += (args) =>
            {
                if (args.IsDownloaded)
                {
                    Console.WriteLine("Update Downloaded. Closing.");
                    return;
                }
                Console.WriteLine("Update Download Failed");
            };
            AutoUpdater.UpdateErrorEvent += (args) =>
            {
                Console.WriteLine("Error : " + args.Message);
            };
            Console.WriteLine("检测更新……");
            AutoUpdater.StartAsync(@"http://192.168.100.165:8083/update.json",serviceName: serviceName);
            
        }
    }
}
